﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FAST
{
    /// <summary>
    /// Record logs of operations.
    /// </summary>
    public class MessageLog
    {
        private string allMsg;
        private string changesMsg;
        private string conflictMsg;
        private string errorMsg;

        //tracking no. of operations.
        private int allMsgCount;
        private int changeMsgCount;
        private int conflictMsgCount;
        private int errorMsgCount;

        public MessageLog()
        {
            this.allMsg = "";
            this.changesMsg = "";
            this.conflictMsg = "";
            this.errorMsg = "";

            allMsgCount = 0;
            changeMsgCount = 0;
            conflictMsgCount = 0;
            errorMsgCount = 0;
        }

        public void appendAllMsg(string newMsg)
        {
            this.allMsg += newMsg;
            this.allMsgCount++;
        }

        public void appendChangesMsg(string newMsg)
        {
            this.changesMsg += newMsg;
            this.changeMsgCount++;
        }

        public void appendConflictMsg(string newMsg)
        {
            this.conflictMsg += newMsg;
            this.conflictMsgCount++;
        }

        public void appendErrorMsg(string newMsg)
        {
            this.errorMsg += newMsg;
            this.errorMsgCount++;
        }

        public string getAllMsg()
        {
            string finalMsg = this.allMsg + "\nTotal Operation(s): " + this.allMsgCount + ".\n";
            return finalMsg;
        }

        public string getChangesMsg()
        {
            string finalMsg = this.changesMsg + "\nTotal File Change(s): " + this.changeMsgCount + ".\n";
            return finalMsg;
        }

        public string getConflictMsg()
        {
            string finalMsg = this.conflictMsg + "\nTotal File or Folder Conflict(s): " + this.conflictMsgCount + ".\n";
            return finalMsg;
        }

        public string getErrorMsg()
        {
            string finalMsg = this.errorMsg + "\nTotal Exception(s): " + this.errorMsgCount + ".\n";
            return finalMsg;
        }

        public int getMsgCount(string type)
        {
            switch (type)
            {
                case "ALL":
                    return this.allMsgCount;
                case "CHANGE":
                    return this.changeMsgCount;
                case "CONFLICT":
                    return this.conflictMsgCount;
                case "ERROR":
                    return this.errorMsgCount;
                default:
                    return -1;
            }
        }

    }
}
